﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using DevPhone.Controls;
using Microsoft.Phone.Controls;

namespace DevPhoneToolkitSample.Samples
{
    public partial class DatePickerBoxSample : PhoneApplicationPage
    {
        public DatePickerBoxSample()
        {
            InitializeComponent();
        }

        private void DropDownControlSelectionChange(object sender, SelectionChangedEventArgs e)
        {
            Dtpk.ShowPart = (WindowsBoxDatePickerShowPart)Enum.Parse(typeof(WindowsBoxDatePickerShowPart), (string)e.AddedItems[0], true);
            switch (Dtpk.ShowPart)
            {
                case WindowsBoxDatePickerShowPart.AllParts:
                    Dtpk.HeaderBox = null;
                    break;
                case WindowsBoxDatePickerShowPart.MonthsAndYears:
                    Dtpk.HeaderBox = "Choose Month and Year";
                    break;
                case WindowsBoxDatePickerShowPart.DaysAndMonthsLeapYear:
                case WindowsBoxDatePickerShowPart.DaysAndMonths:
                    Dtpk.HeaderBox = "Choose Month and Day";
                    break;
                case WindowsBoxDatePickerShowPart.OnlyDays31:
                case WindowsBoxDatePickerShowPart.OnlyDays30:
                case WindowsBoxDatePickerShowPart.OnlyDays29:
                case WindowsBoxDatePickerShowPart.OnlyDays28:
                    Dtpk.HeaderBox = "Choose Day";
                    break;
                case WindowsBoxDatePickerShowPart.OnlyMonths:
                    Dtpk.HeaderBox = "Choose Month";
                    break;
                case WindowsBoxDatePickerShowPart.OnlyYears:
                    Dtpk.HeaderBox = "Choose Year";
                    break;
            }
        }

        private void ChkIcoClick(object sender, RoutedEventArgs e)
        {
            // ReSharper disable PossibleInvalidOperationException
            Dtpk.ShowIcon = ChkIco.IsChecked.Value;
            // ReSharper restore PossibleInvalidOperationException
        }

        private void ChkIcoExtClick(object sender, RoutedEventArgs e)
        {
            // ReSharper disable PossibleInvalidOperationException
            if ((bool) ChkIcoExt.IsChecked)
            // ReSharper restore PossibleInvalidOperationException
            {
                var externalicon = new BitmapImage(new Uri("/Images/star.png", UriKind.Relative));
                Dtpk.ExternalIcon = externalicon;
            }
            else
            {
                Dtpk.ExternalIcon = null;
            }
        }
    }
}